<template>
  <div class="recommend">
    <ul class="three">
      <li v-for="v in arrthree" :key="v.id" @click="skip(v.id)">
        <img :src="v.imgsrc" alt="" class="img_top" />
        <h5>{{ v.title }}</h5>
        <p>
          ￥{{ v.newprice }} <span>￥{{ v.oldprice }}</span>
        </p>
        <span class="img_bottom"></span>
      </li>
    </ul>
    <img :src="v.imgsrc" alt="" class="img_t" v-for="(v, i) in imgt" :key="i" />
    <span class="more" @click="jump">更多></span>
    <van-tabs v-model="active" >
      <van-tab title="下午茶">
        <ul class="tea">
          <li v-for="(v, i) in newli" :key="i">
            <img :src="v.goodsImg" alt="" class="img_tea" />
            <h4>{{ v.title }}</h4>
            <p>
              <i>￥{{ v.goodsLowPrice }}</i> <i>￥{{ v.goodsHighPrice }}</i>
            </p>
            <span class="zp">赠品</span>
            <p>
              已售卖&nbsp;{{ v.saleNumber }}
              件
              <span class="img_right"></span>
            </p>
          </li>
        </ul>
      </van-tab>
      <van-tab title="生活家居">
        <ul class="tea">
          <li v-for="(v, i) in newli2" :key="i">
            <img :src="v.goodsImg" alt="" class="img_tea" />
            <h4>{{ v.title }}</h4>
            <p>
              <i>￥{{ v.goodsLowPrice }}</i> <i>￥{{ v.goodsHighPrice }}</i>
            </p>
            <span class="zp">赠品</span>
            <p>
              已售卖&nbsp;{{ v.saleNumber }}
              件
              <span class="img_right"></span>
            </p>
          </li>
        </ul>
      </van-tab>
      <van-tab title="数码电器">
        <ul class="tea">
          <li v-for="(v, i) in newli3" :key="i">
            <img :src="v.goodsImg" alt="" class="img_tea" />
            <h4>{{ v.title }}</h4>
            <p>
              <i>￥{{ v.goodsLowPrice }}</i> <i>￥{{ v.goodsHighPrice }}</i>
            </p>
            <span class="zp">赠品</span>
            <p>
              已售卖&nbsp;{{ v.saleNumber }}
              件
              <span class="img_right"></span>
            </p>
          </li>
        </ul>
      </van-tab>
      <van-tab title="啊玩饰品">
        <ul class="tea">
          <li v-for="(v, i) in newli4" :key="i">
            <img :src="v.goodsImg" alt="" class="img_tea" />
            <h4>{{ v.title }}</h4>
            <p>
              <i>￥{{ v.goodsLowPrice }}</i> <i>￥{{ v.goodsHighPrice }}</i>
            </p>
            <span class="zp">赠品</span>
            <p>
              已售卖&nbsp;{{ v.saleNumber }}
              件
              <span class="img_right"></span>
            </p>
          </li>
        </ul>
      </van-tab>
      <van-tab title="" disabled></van-tab>
    </van-tabs>
  </div>
</template>

<script>
import axios from "axios";
export default {
  created() {
    // axios({
    //   url: "/api/goods/findbyId",
    //   params: {
    //     id: 4,
    //   },
    // }).then((res) => {
    //   // console.log(res.data.data);
    //   this.newli = res.data.data;
    // });
    // axios({
    //   url: "/api/goods/findbyId",
    //   params: {
    //     id: 5,
    //   },
    // }).then((res) => {
    //   this.newli2 = res.data.data;
    // });
    //------------------------
    let _that = this;
    function newli() {
      return axios.get("/api/goods/findGoodsByType?typeId=4");
    }

    function newli2() {
      return axios.get("/api/goods/findGoodsByType?typeId=5");
    }
    function newli3() {
      return axios.get("/api/goods/findGoodsByType?typeId=6");
    }
    function newli4() {
      return axios.get("/api/goods/findGoodsByType?typeId=7");
    }
    axios.all([newli(), newli2(), newli3(), newli4()]).then(
      axios.spread(function (newli, newli2, newli3, newli4) {
        // console.log("newli.data.data",newli.data.data);
        console.log(newli2.data.data);
        _that.newli = newli.data.data;
        _that.newli2 = newli2.data.data;
        _that.newli3 = newli3.data.data;
        _that.newli4 = newli4.data.data;
        // console.log(_that);
      })
    );
  },
  methods: {
    jump() {
      this.$router.push("/login");
    },
    skip(id) {
      console.log(id);

      this.$router.push("/shopp/" + id);
    },
  },
  data() {
    return {
      active: 0,
      arrthree: [
        {
          id: "1001",
          imgsrc: "/lsc/three01.jpg",
          title: "生椰拿铁",
          newprice: "18",
          oldprice: "24",
        },
        {
          id: "1002",
          imgsrc: "/lsc/three01.jpg",
          title: "厚乳拿铁",
          newprice: "16",
          oldprice: "24",
        },
        {
          id: "1003",
          imgsrc: "/lsc/three01.jpg",
          title: "标准美式",
          newprice: "13",
          oldprice: "23",
        },
      ],
      imgt: [
        {
          imgsrc: "/lsc/two01.jpg",
        },
        {
          imgsrc: "/lsc/two01.jpg",
        },
      ],
      newli: [
      
      ],
      newli2: [],
      newli3: [],
      newli4: [],
    };
  },
};
</script>

<style scoped>
.recommend {
  width: 95%;
  margin: 0 auto;
  height: 1.5rem;
  background-color: #fff;
}
.recommend .three {
  display: flex;
  justify-content: space-between;
}
.recommend li {
  width: 1rem;
  height: 1.5rem;
  box-sizing: border-box;
  /* border: 0.01rem solid black; */
  background-color: #fff;
  position: relative;
}
.recommend .img_top {
  width: 1rem;
  height: 0.96rem;
}

.recommend h5 {
  font-size: 0.12rem;
}
.recommend p {
  height: 0.3rem;
  line-height: 0.3rem;
  font-size: 0.12rem;
  color: red;
  position: relative;
}
.recommend p span:nth-of-type(1) {
  color: #999999;
  text-decoration: line-through;
}
.recommend p .img_right {
  display: inline-block;
  width: 0.2rem;
  height: 0.2rem;
  border-radius: 50%;
  background: url(../../assets/lsc/car.jpg) no-repeat center;
  background-size: 0.2rem 0.2rem;
  position: absolute;
  top: 0.02rem;
  right: 0.1rem;
}
.recommend .img_bottom {
  display: inline-block;
  width: 0.2rem;
  height: 0.2rem;
  border-radius: 50%;
  background: url(../../assets/lsc/add.jpg) no-repeat center;
  background-size: 0.2rem 0.2rem;
  position: absolute;
  bottom: 0.1rem;
  right: 0.05rem;
}
.img_t {
  display: block;
  width: 95%;
  margin: 0.15rem auto;
}
.recommend .tea {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  min-height:4rem
}
.tea li {
  width: 1.7rem;
  height: 2.3rem;
  margin: 0.1rem 0;
  border-radius: 0.08rem;
  /* border: 0.01rem solid black; */
  background-color: #fff;
  float: left;
}
.tea li .img_tea {
  width: 100%;
  height: 1.3rem;
  border-top-left-radius: 0.08rem;
  border-top-right-radius: 0.08rem;
  background-color: oldlace;
}
.tea li h4 {
  font-weight: 400;
  font-size: 0.12rem;
  text-indent: 1em;
}
.tea li p {
  text-indent: 1em;
}
.tea li p i {
  font-style: normal;
}
.tea li p i:nth-of-type(1) {
  color: orange;
  font-size: 0.14rem;
}
.tea li p i:nth-of-type(2) {
  color: gray;
  text-decoration: line-through;
  margin-left: 0.05rem;
}
.tea li .zp {
  display: block;
  width: 0.36rem;
  height: 0.2rem;
  line-height: 0.2rem;
  text-align: center;
  color: orange;
  font-size: 0.09rem;
  transform: scale(0.8);
  background-color: #fce6df;
  margin-left: 0.07rem;
}
.more {
  display: inline-block;
  color: #ccc;
  font-size: 0.14rem;
  position: relative;
  left: 3rem;
  top: 0.29rem;
  z-index: 999;
}
</style>